home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
prog
/
cenvi29.arj
/
FRANTICK.CMM
< prev
next >
Wrap
Text File
|
1994-03-04
|
1KB
|
43 lines
//*******************************************************
//*** Frantick.cmm - silly CEnvi program to bounce an ***
//*** ver.1 asterisk around the screen ***
//*******************************************************
// find out how big the screen is
MaxRow = ScreenSize().row - 1;
MaxCol = ScreenSize().col - 1;
// get a random initial position for the bouncy asterisk
srand();
OldRow = rand() % (MaxRow + 1);
OldCol = rand() % (MaxCol + 1);
// clear the screen to start with a fesh slate
ScreenClear();
while ( !kbhit() ) {
// draw new dots and erase old ones forever
do {
// calculate new row, so long as it is in bounds
Row = OldRow + (rand() % 3) - 1;
} while( Row < 0 || MaxRow < Row );
do {
// calculate new column, so long as it is in bounds
Col = OldCol + (rand() % 3) - 1;
} while( Col < 0 || MaxCol < Col );
SafePutchar(' ',OldRow,OldCol);
SafePutchar('*',OldRow = Row,OldCol = Col);
}
SafePutchar(c,row,col) // just like putchar, but won't write into lower-right corner
{ // so we don't get accidental scrolling
ScreenCursor(col,row);
if ( row != MaxRow || col != MaxCol ) {
putchar(c);
}
ScreenCursor(col,row);
}
// flush the keyboard
while( kbhit() ) getch();